<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
	</head>

	<body>
		<p>
			<input type="button" value="test" onclick="A().hello()" />
		</p>
		<script>
			var A = function() {
				var a = {
					hello: function() {
						alert('hello world');
					}
				};

				return a;
			}

			var B = function(options) {
				this.name = options['name'] || 'guest'
			};

			B.prototype = {
				//constructor:B,       
				hello: function() {
					alert('hello ' + this.name);
				}
			}

			var b = new B({
				name: 'jack'
			});
			b.hello();
		</script>
	</body>

</html>